<?php
class mcz_Permission extends mcz_Object
{
	protected $fields = array(
		'id' => array('cast' => 'integer'),
		'label' => array('cast' => 'string',
						 'unique' => true,
						 'notblank' => true)
	);

	public static function store($label)
	{
		$res = self::hydrate(get_class(),
							 self::dbh()->fetch('* from ' . get_class() .
												' where label = ?', array($label)));
		if($res)
		{
			return $res[0];
		}
		$res = new mcz_Permission();
		$res->label = $label;
		$res->save();
		return $res;
	}
}